The chief power of HTML comes from its ability to link regions of text (and also images) to another document. The browser highlights these regions (usually with color and/or underlines) to indicate that they are hypertext links (often shortened to hyperlinks or simply links).
HTML's single hypertext-related tag is <A>, which stands for anchor. To include an anchor in your document:
1. Start the anchor with <A . (There's a space after the A.)
2. Specify the document that's being pointed to by entering the parameter
HREF="filename" followed by a closing right angle bracket: >
3. Enter the text that will serve as the hypertext link in the current document.
4. Enter the ending anchor tag: </A>.
Here is an sample hypertext reference:
<A HREF="MaineStats.html">Maine</A>
This entry makes the word "Maine'' the hyperlink to the document MaineStats.html, which is in the same directory as the first document. You can link to documents in other directories by specifying the relative path from the current document to the linked document. For example, a link to a file NJStats.html located in the subdirectory AtlanticStates would be:
These are called relative links. You can also use the absolute pathname of the file if you wish. Pathnames use the standard UNIX syntax.
Relative Links Versus Absolute Pathnames
In general, you should use relative links, because
1. You have less to type.
2. It's easier to move a group of documents to another location, because the
relative path names will still be valid.
However, use absolute pathnames when linking to documents that are not directly related. For example, consider a group of documents that comprise a user manual. Links within this group should be relative links. Links to other documents (perhaps a reference to related software) should use full path names. This way, if you move the user manual to a different directory, none of the links would have to be updated.
Uniform Resource Locator
The World Wide Web uses Uniform Resource Locators (URLs) to specify the location of files on other servers. A URL includes the type of resource being accessed (e.g., gopher, WAIS), the address of the server, and the location of the file. The syntax is:
scheme://host.domain[:port]/path/filename
where scheme is one of
file
a file on your local system, or a file on an anonymous FTP server
http
a file on a World Wide Web server
gopher
a file on a Gopher server
WAIS
a file on a WAIS server
news
an Usenet newsgroup
telnet
a connection to a Telnet-based service
The port number can generally be omitted. (That means unless someone tells you otherwise, leave it out.)
For example, to include a link to this primer in your document, you would use
A Beginner's Guide to URLs, located on the NCSA Mosaic Help menu
http://www.ncsa.uiuc.edu/demoweb/url-primer.html
Links to Specific Sections in Other Documents
Anchors can also be used to move to a particular section in a document. Suppose you wish to set a link from document A and a specific section in document B. (Call this file documentB.html.) First you need to set up a named anchor in document B. For example, to set up an anchor named "Jabberwocky'' to document B, enter
Here's <A NAME = "Jabberwocky">some text</a>
Now when you create the link in document A, include not only the filename, but also the named anchor, separated by a hash mark (#).
This is my <A HREF = "documentB.html#Jabberwocky">link</A> to document B.
Now clicking on the word "link'' in document A sends the reader directly to the words "some text'' in document B.
Links to Specific Sections Within the Current Document
The technique is exactly the same except the filename is omitted.
For example, to link to the Jabberwocky anchor from within the same file (Document B), use
This is <A HREF="#Jabberwocky">Jabberwocky link</A> from within Document B.